package com.ysx.user.controller;

import com.ysx.common.pojo.Result;
import com.ysx.core.controller.AbstractCoreController;
import com.ysx.user.pojo.ApUserRealname;
import com.ysx.user.service.ApUserRealnameService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* <p>
* APP实名认证信息表 控制器</p>
* @author ljh
* @since 2021-09-08
*/
@Api(value="APP实名认证信息表",tags = "ApUserRealnameController")
@RestController
@RequestMapping("/apUserRealname")
@Slf4j
public class ApUserRealnameController extends AbstractCoreController<ApUserRealname> {

    private ApUserRealnameService apUserRealnameService;

    //注入
    @Autowired
    public ApUserRealnameController(ApUserRealnameService apUserRealnameService) {
        super(apUserRealnameService);
        this.apUserRealnameService=apUserRealnameService;
    }

    //审核通过
    @PutMapping("/auditPass/{id}")
    public Result auditPass(@PathVariable("id")Long id) {
        try {
            apUserRealnameService.auditPass(id);
            return Result.ok();
        } catch (Exception e) {
            return Result.error("审核出现了问题，异常信息："+e);
        }
    }

    //审核失败
    @PutMapping("/auditFailure/{id}")
    public Result auditFailure(@PathVariable("id")Long id, @RequestParam String reason) {
//        try {

            apUserRealnameService.auditFailure(id,reason);
            return Result.ok();
        /*} catch (Exception e) {
            return Result.error("审核出现了问题，异常信息："+e);
        }*/
    }
}

